<template>


  <el-form :inline="true" :model="formInline" class="demo-form-inline">
    <el-form-item label="产品编号">
      <el-input v-model="formInline.PurchaseId" placeholder="请输入" clearable />
    </el-form-item>

    <el-form-item label="产品命称">
      <el-input v-model="formInline.ProductName" placeholder="请输入" clearable />
    </el-form-item>
    <el-form-item label="仓库">
      <el-input v-model="formInline.LocationId" placeholder="请输入" clearable />
    </el-form-item>
    <el-form-item label="产品批次">
      <el-input v-model="formInline.Bacth" placeholder="请输入" clearable />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="Show()" style="width: 100px;">查询</el-button>
    </el-form-item>
  </el-form>

  <el-form :inline="true">
    <el-form-item>
      <el-button type="primary" @click="DeleteAll()">删除</el-button>
      <el-button type="primary" @click="Show()">刷新</el-button>
      <el-button type="primary" @click="OppenExports()">导出</el-button>
    </el-form-item>
  </el-form>

  <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
    <el-table-column prop="accountId" label="序号" width="auto">
      <template v-slot="scope">
        <el-checkbox-group v-model="addIds">
          <el-checkbox :value="scope.row.accountId">{{ scope.row.accountId }}</el-checkbox>
        </el-checkbox-group>
      </template>
    </el-table-column>

    <el-table-column prop="preparer" label="货品编号" width="auto" >
      <template v-slot="scope">
                <span @click="Gochange(scope.row.preparer)" style="color: green;">{{ scope.row.preparer }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="product_Name" label="货品名称" width="auto" />
    <el-table-column prop="product_Type" label="货品类型" width="auto" />
    <el-table-column prop="product_RuleNumber" label="规格型号" width="auto" />
    <el-table-column prop="weight" label="单位" width="auto" />
    <el-table-column prop="warehouse_Name" label="仓库名称" width="auto" />
    <el-table-column prop="please_Name" label="仓位名称" width="auto" />
    <el-table-column prop="quantity" label="当前库存" width="auto" />
    <el-table-column prop="depName" label="批次" width="auto" />
    <el-table-column prop="startDate" label="生产日期" width="auto" />
    <el-table-column prop="endDate" label="到期日期" width="auto" />
    <el-table-column label="操作" width="auto" />
  </el-table>
  <table>
    <thead>
      <tr>
        <td>
          <el-pagination v-model:current-page="Page.pageIndex" v-model:page-size="Page.pageSize"
            :page-sizes="[15, 20, 30, 40]" :background="true" layout="total, sizes, prev, pager, next, jumper,slot"
            :total="Page.total" prev-text="上一页" next-text="下一页">
            共{{ Page.total }}条，共{{ Page.pageIndex }}\{{ Page.totalPage }}页
          </el-pagination>
        </td>
      </tr>
    </thead>

  </table>
  <div class="table-footer">
    <div class="batch-actions">
      <el-button size="small" @click="selectAll()">全选</el-button>
      <el-button size="small" @click="reverseSelect()">反选</el-button>
      <el-select size="small" placeholder="批量操作" style="width: 120px;">
        <el-option label="批量删除" value="delete" @click="DeleteAll()" />
        <el-option label="批量导出" value="export" @click="OppenExportsAll()" />
      </el-select>
    </div>
  </div>
</template>
<script lang="ts" setup>


import { http } from '@/axios/axiosHelpers'
import { systeamread } from '@/systeamaxios/sysaxiosHelpers';
import axios from 'axios';

import { ElMessage } from 'element-plus'
import { onMounted, reactive, ref } from 'vue'
const addIds = ref<any>([])
const dialogVisible = ref(false)
const LogExport = ref(false)
const bt = reactive({
  bid: 0,
  bname: ""
})
//表格加入
const Page = reactive({
  pageIndex: 1,
  pageSize: 15,
  total: 0,
  totalPage: 0
})
//表格查询
const formInline = reactive({
  PurchaseId: '',
  ProductName: '',
  LocationId: '',
  Bacth: ''
})//表格
const tableData = ref([{
  "accountId": 0,
  "preparer": "",
  "depName": "",
  "accountTime": "",
  "typeId": 0,
  "startDate": "",
  "endDate": "",
  "inventoryId": 0,
  "userId": 0,
  "remarks": "string",
  "isDel": true,
  "ledgerInfoManagement_Id": 0,
  "product_Code": "",
  "product_Name": "",
  "product_Status": "",
  "product_Type": "",
  "product_RuleNumber": "",
  "weight": "",
  "numberData": "",
  "warehouse_Name": "",
  "please_Name": "",
  "quantity": 0,
  "money": 0,
  "wating_Into": 0,
  "wating_Out": 0,
  "storage_Unit": 0,
  "storage_Money": 0,
  "start_Unit": 0,
  "end_Unit": 0
}])
const Gochange=(code:string)=>{

}
const OppenExports = () => {
  LogExport.value = true
}
onMounted(() => {
  Show()
})

//显示信息
const Show = () => {
  // http.get("/managementsysteamreadapis/api/DepartMentAll/ShowDepartMent", {
  systeamread.get("/api/LedgerManagementAll/ShowLedAccout", {
    params: {
      PageIndex: Page.pageIndex,
      PageSize: Page.pageSize,
    }
  })
    .then(res => {
      tableData.value = res.data.data.data
      Page.total = res.data.total
      addIds.value = []
    })
}

//保存选中的id
const handleSelectionChange = (selection: any[]) => {
  addIds.value = selection.map(item => item.rabit_Id)
}
//全部选中id
const selectAll = () => {
  addIds.value = tableData.value.map(item => item.accountId)
}
//反选
const reverseSelect = () => {
  addIds.value = tableData.value.filter(item => !addIds.value.includes(item.accountId)).map(item => item.accountId)
}

const OppenExportsAll = () => {
  // let url ="http://112.126.93.146:8000/managementsysteamreadapis/api/ExportAll/DepartmentAll?Ids=" + addIds.value.toString();
  let url = "http://112.126.93.146:8000/managementsysteamreadapis/api/ExportAll/DepartmentAll?Ids=" + addIds.value.toString();
  window.location.href = url
  addIds.value = []
}
const DeleteAll = () => {

}

</script>